<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition template="/template.xhtml"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core" >

    <ui:define name="title">
        <h:outputText value="#{bundle.CreateUserTitle}"></h:outputText>
    </ui:define>
    <ui:define name="body">
        <h:form styleClass="form list">
            <p:fieldset legend="User Creation" id="user_create"  rendered="#{userController.allowedGroups('2')}">
                <h:panelGrid columns="2" columnClasses="label,field" styleClass="form_list">
                    <h:outputLabel value="#{bundle.CreateUserLabel_userLogin}" for="userLogin" />
                    <p:inputText id="userLogin" label="User Login" value="#{userController.current.userLogin}" title="#{bundle.CreateUserTitle_userLogin}" required="true" requiredMessage="#{bundle.CreateUserRequiredMessage_userLogin}">
                        <f:ajax event="blur" listener="#{userController.validate()}"/>
                        <f:validateLength minimum="4"  maximum="45"   />
                    </p:inputText>
                    <h:outputLabel value="#{bundle.CreateUserLabel_userEmail}" for="userEmail" />
                    <p:inputText id="userEmail" label="Email" value="#{userController.current.userEmail}"  required="true" validatorMessage="Not a valid email" requiredMessage="#{bundle.CreateUserRequiredMessage_userEmail}"  >
                        <f:validateRegex  pattern="[\w\.-]*[a-zA-Z0-9_]@[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]"  />
                    </p:inputText>
                    <h:outputLabel value="#{bundle.CreateUserLabel_userPass}" for="userPass" />
                    <p:password feedback="true" id="userPass" value="#{userController.current.userPass}" title="#{bundle.CreateUserTitle_userPass}" required="true" requiredMessage="#{bundle.CreateUserRequiredMessage_userPass}"/>

                    <h:outputLabel value="#{bundle.CreateUserLabel_userLive}"  />
                    <p:selectBooleanCheckbox value="#{userController.current.userLive}"/>
                </h:panelGrid>
                <br />
                <p:commandButton ajax="false" action="#{userController.create}" value="Save" process="@form" update="@form" />
                <p:commandButton ajax="false" action="#{userController.prepareList}" value="Show All" immediate="true"/>

            </p:fieldset>
        </h:form>
    </ui:define>
</ui:composition>

